<template>
	<view class="contnet">
		<view class="header">
			<view>总收入</view>
			<view>{{ totalMoney }}元</view>
		</view>
		<view class="list-box">
			<view v-if="list.length > 0">
				<block v-for="(item, index) in list" :key="index">
					<view class="list-box__li" @tap="jumpPage(item.type)">
						<view class="list-box__li-title">
							<view>{{ item.key }}</view>
							<text class="iconfont icon-xiayiye"></text>
						</view>
						<view class="list-box__li-value">
							<view class="left">
								<view>订单笔数</view>
								<view class="num">{{ item.num }}</view>
							</view>
							<view class="right">
								<view>金额</view>
								<view class="num">￥{{ item.money }}</view>
							</view>
						</view>
					</view>
				</block>
			</view>
			<LoadMore v-else :empty="true" emptyText="暂无数据"></LoadMore>
		</view>
		<!--智能搜索-->
		<ai-search ref="aiSearch"></ai-search>
	</view>
</template>

<script>
import LoadMore from '@/components/LoadMore';

export default {
	data() {
		return {
			params: {
				page: 1,
				size: 15
			},
			list: [],
			totalMoney: 0
		};
	},
	components: {
		LoadMore
	},
	mounted() {
		this.getList({ ...this.params });
	},
	onShow() {
		this.$nextTick(() => {
			uni.getClipboardData({
				success: res => {
					if (res.data && this.$store.state.common.aiSearch) {
						this.$refs.aiSearch.open(res.data);
						this.$store.commit({
							type: 'setAiSearch',
							aiSearch: false
						});
					}
				}
			});
		});
	},
	onHide() {
		this.$refs.aiSearch.close();
	},

	methods: {
		getList(params) {
			this.$service.member.userHf
				.cumulativeSubsidy(params)
				.then(res => {
					this.list = res.list;
					this.totalMoney = res.subDate.totalMoney;
					uni.stopPullDownRefresh();
				})
				.catch(err => {
					uni.showToast({
						icon: 'none',
						title: err.message
					});
					uni.stopPullDownRefresh();
				});
		},
		dataNext(list) {
			if (this.pagination.page > 1) {
				this.list = this.list.concat(list);
			} else {
				this.list = list;
			}
		},
		jumpPage(index) {
			if (index == 1) {
				this.$Router.push('/pages/member/order');
			} else if (index == 2) {
				this.$Router.push('/pages/integral/money');
			}
		}
	},
	onPullDownRefresh() {
		this.getList({
			...this.params,
			page: 1
		});
	}
};
</script>
<style lang="scss" scoped>
.contnet {
	.header {
		width: 100%;
		height: 128rpx;
		background: #f70114;
		@include flexBox(space-between, center);
		padding: 0 48rpx;
		color: #ffffff;
		font-size: 32rpx;
	}
	.list-box {
		&__li {
			width: 714rpx;
			height: 258rpx;
			margin: auto;
			margin-top: 20rpx;
			border-radius: 20rpx;
			background: #ffffff;
			padding: 28rpx 36rpx 36rpx 36rpx;
			&-title {
				@include flexBox(space-between, center);
				color: #171717;
				font-size: 28rpx;
				.iconfont {
					color: #86828c;
				}
			}
			&-value {
				@include flexBox(space-between, center);
				font-size: 28rpx;
				color: #717076;
				text-align: center;
				margin-top: 48rpx;
				.left {
					.num {
						margin-top: 24rpx;
						color: #221d2c;
					}
				}
				.right {
					.num {
						margin-top: 24rpx;
						color: #f70114;
					}
				}
			}
		}
	}
}
</style>
